
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>git - 简明指南 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="../开发者指南.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../开源组件实现.html">
            
                <a href="../开源组件实现.html">
            
                    
                    开源组件实现
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../mvc/MVC框架实现篇.html">
            
                <a href="../mvc/MVC框架实现篇.html">
            
                    
                    MVC框架实现篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="../mvc/">
            
                <a href="../mvc/">
            
                    
                    MVC框架实现篇
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.2" data-path="../mvc/1.plan.html">
            
                <a href="../mvc/1.plan.html">
            
                    
                    项目规划
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.3" data-path="../mvc/2.route.html">
            
                <a href="../mvc/2.route.html">
            
                    
                    路由设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.4" data-path="../mvc/3.controller.html">
            
                <a href="../mvc/3.controller.html">
            
                    
                    控制器设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.5" data-path="../mvc/4.config.html">
            
                <a href="../mvc/4.config.html">
            
                    
                    配置设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.6" data-path="../mvc/5.view.html">
            
                <a href="../mvc/5.view.html">
            
                    
                    视图设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.7" data-path="../mvc/6.dbutil.html">
            
                <a href="../mvc/6.dbutil.html">
            
                    
                    数据库操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.8" data-path="../mvc/7.crud.html">
            
                <a href="../mvc/7.crud.html">
            
                    
                    增删改查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../ioc/IOC容器实现篇.html">
            
                <a href="../ioc/IOC容器实现篇.html">
            
                    
                    IOC容器实现篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.2.1" data-path="../ioc/1.concept.html">
            
                <a href="../ioc/1.concept.html">
            
                    
                    IOC的概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.2" data-path="../ioc/2.spring.html">
            
                <a href="../ioc/2.spring.html">
            
                    
                    Spring中怎么用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.3" data-path="../ioc/3.myioc.html">
            
                <a href="../ioc/3.myioc.html">
            
                    
                    设计一个IOC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2.4" data-path="../ioc/4.principle.html">
            
                <a href="../ioc/4.principle.html">
            
                    
                    原理分析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../设计模式系列.html">
            
                <a href="../设计模式系列.html">
            
                    
                    设计模式系列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../designpatterns/singleton.html">
            
                <a href="../designpatterns/singleton.html">
            
                    
                    如何正确地写出单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../designpatterns/proxy.html">
            
                <a href="../designpatterns/proxy.html">
            
                    
                    代理模式剖析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../designpatterns/strategy.html">
            
                <a href="../designpatterns/strategy.html">
            
                    
                    什么是策略模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Java8系列.html">
            
                <a href="../Java8系列.html">
            
                    
                    Java8系列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../java8/java8-guide.html">
            
                <a href="../java8/java8-guide.html">
            
                    
                    Java8简明教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../java8/foreach.html">
            
                <a href="../java8/foreach.html">
            
                    
                    Java8 Foreach
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Hexo搭建博客.html">
            
                <a href="../Hexo搭建博客.html">
            
                    
                    Hexo搭建博客
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../hexo/hello.html">
            
                <a href="../hexo/hello.html">
            
                    
                    分分钟部署一个Hexo环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../hexo/config.html">
            
                <a href="../hexo/config.html">
            
                    
                    各种配置详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../hexo/writing.html">
            
                <a href="../hexo/writing.html">
            
                    
                    开始写作吧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../开发者指南.html">
            
                <a href="../开发者指南.html">
            
                    
                    开发者指南
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.6.1" data-path="guide.html">
            
                <a href="guide.html">
            
                    
                    git - 简明指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" >
            
                <a target="_blank" href="https://waylau.gitbooks.io/jersey-2-user-guide/content/index.html">
            
                    
                    Jersey-2.x用户指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" >
            
                <a target="_blank" href="https://waylau.gitbooks.io/rest-in-action/content/">
            
                    
                    REST 实战
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" >
            
                <a target="_blank" href="https://github.com/waylau/servlet-3.1-specification">
            
                    
                    Java Servlet 3.1 规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" >
            
                <a target="_blank" href="http://mybatis.github.io/mybatis-3/zh/index.html">
            
                    
                    MyBatis中文指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" >
            
                <a target="_blank" href="https://github.com/waylau/apache-shiro-1.2.x-reference">
            
                    
                    Apache Shiro 用户指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" >
            
                <a target="_blank" href="https://github.com/qibaoguang/Spring-Boot-Reference-Guide/blob/master/SUMMARY.md">
            
                    
                    Spring Boot参考指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" >
            
                <a target="_blank" href="https://github.com/waylau/netty-4-user-guide/blob/master/SUMMARY.md">
            
                    
                    Netty4 用户指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../user_guide/google-java8-guide.html">
            
                <a href="../user_guide/google-java8-guide.html">
            
                    
                    Google Java编程风格指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../运维相关.html">
            
                <a href="../运维相关.html">
            
                    
                    运维相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../web/test_tool.html">
            
                <a href="../web/test_tool.html">
            
                    
                    Web性能测试工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" >
            
                <a target="_blank" href="https://github.com/judasn/Linux-Tutorial">
            
                    
                    Java 程序员眼中的 Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../learn_server/">
            
                <a href="../learn_server/">
            
                    
                    写给java开发的运维笔记
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../经典文章.html">
            
                <a href="../经典文章.html">
            
                    
                    经典文章
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../articles/request_message.html">
            
                <a href="../articles/request_message.html">
            
                    
                    HTTP请求报文解剖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../articles/software_architecture_patterns.html">
            
                <a href="../articles/software_architecture_patterns.html">
            
                    
                    软件架构模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../articles/electrical-business-architecture.html">
            
                <a href="../articles/electrical-business-architecture.html">
            
                    
                    电商网站架构案例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../服务器相关.html">
            
                <a href="../服务器相关.html">
            
                    
                    服务器/域名/SSL证书
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" >
            
                <a target="_blank" href="https://domainr.com">
            
                    
                    可用域名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" >
            
                <a target="_blank" href="http://hk.hostsir.com/Affiliates/i/d/976">
            
                    
                    优惠域名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" >
            
                <a target="_blank" href="http://www.vultr.com/?ref=6886447">
            
                    
                    vultr VPS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" >
            
                <a target="_blank" href="https://sshdropbear.net/">
            
                    
                    免费VPN/SSH服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" >
            
                <a target="_blank" href="http://get.ishadow.website/">
            
                    
                    免费SS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" >
            
                <span>
            
                    
                    1小时免费VPN
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" >
            
                <a target="_blank" href="https://saki.ssl.do/aff.php?aff=11">
            
                    
                    SSL.DO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.8" >
            
                <a target="_blank" href="http://api.hostinger.com.hk/redir/22018310">
            
                    
                    免费虚拟主机
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../实用工具.html">
            
                <a href="../实用工具.html">
            
                    
                    实用工具/API
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" >
            
                <a target="_blank" href="https://tinypng.com/">
            
                    
                    PNG图片无损压缩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" >
            
                <a target="_blank" href="http://tool.c7sky.com/image-watermark/">
            
                    
                    在线给图片加水印
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" >
            
                <a target="_blank" href="http://tool.c7sky.com/password/">
            
                    
                    随机密码生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" >
            
                <a target="_blank" href="https://randomuser.me/">
            
                    
                    随机头像生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" >
            
                <a target="_blank" href="http://tool.c7sky.com/tcleaner/">
            
                    
                    微博一键清理工具
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" >
            
                <a target="_blank" href="http://csscompressor.com/">
            
                    
                    CSS压缩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" >
            
                <a target="_blank" href="http://www.atool.org/">
            
                    
                    在线工具
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >git - 简明指南</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="git---&#x7B80;&#x660E;&#x6307;&#x5357;">git - &#x7B80;&#x660E;&#x6307;&#x5357;</h1>
<blockquote>
<p>&#x52A9;&#x4F60;&#x5165;&#x95E8; git &#x7684;&#x7B80;&#x660E;&#x6307;&#x5357;&#xFF0C;&#x6728;&#x6709;&#x9AD8;&#x6DF1;&#x5185;&#x5BB9; ;)</p>
</blockquote>
<h2 id="&#x5B89;&#x88C5;">&#x5B89;&#x88C5;</h2>
<ul>
<li><a href="http://code.google.com/p/git-osx-installer/downloads/list?can=3" target="_blank">&#x4E0B;&#x8F7D; git OSX &#x7248;</a></li>
<li><a href="http://msysgit.github.io/" target="_blank">&#x4E0B;&#x8F7D; git Windows &#x7248;</a></li>
<li><a href="http://book.git-scm.com/2_installing_git.html" target="_blank">&#x4E0B;&#x8F7D; git Linux &#x7248;</a></li>
</ul>
<h2 id="&#x521B;&#x5EFA;&#x65B0;&#x4ED3;&#x5E93;">&#x521B;&#x5EFA;&#x65B0;&#x4ED3;&#x5E93;</h2>
<p>&#x521B;&#x5EFA;&#x65B0;&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x6253;&#x5F00;&#xFF0C;&#x7136;&#x540E;&#x6267;&#x884C; </p>
<pre><code class="lang-sh">git init
</code></pre>
<p>&#x4EE5;&#x521B;&#x5EFA;&#x65B0;&#x7684; git &#x4ED3;&#x5E93;&#x3002;</p>
<h2 id="&#x68C0;&#x51FA;&#x4ED3;&#x5E93;">&#x68C0;&#x51FA;&#x4ED3;&#x5E93;</h2>
<p>&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x7684;&#x514B;&#x9686;&#x7248;&#x672C;&#xFF1A;</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> /path/to/repository
</code></pre>
<p>&#x5982;&#x679C;&#x662F;&#x8FDC;&#x7AEF;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x7684;&#x4ED3;&#x5E93;&#xFF0C;&#x4F60;&#x7684;&#x547D;&#x4EE4;&#x4F1A;&#x662F;&#x8FD9;&#x4E2A;&#x6837;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> username@host:/path/to/repository
</code></pre>
<h2 id="&#x5DE5;&#x4F5C;&#x6D41;">&#x5DE5;&#x4F5C;&#x6D41;</h2>
<p>&#x4F60;&#x7684;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x7531; git &#x7EF4;&#x62A4;&#x7684;&#x4E09;&#x68F5;&#x201C;&#x6811;&#x201D;&#x7EC4;&#x6210;&#x3002;&#x7B2C;&#x4E00;&#x4E2A;&#x662F;&#x4F60;&#x7684; <code>&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;</code>&#xFF0C;&#x5B83;&#x6301;&#x6709;&#x5B9E;&#x9645;&#x6587;&#x4EF6;&#xFF1B;&#x7B2C;&#x4E8C;&#x4E2A;&#x662F; <code>&#x6682;&#x5B58;&#x533A;&#xFF08;Index&#xFF09;</code>&#xFF0C;&#x5B83;&#x50CF;&#x4E2A;&#x7F13;&#x5B58;&#x533A;&#x57DF;&#xFF0C;&#x4E34;&#x65F6;&#x4FDD;&#x5B58;&#x4F60;&#x7684;&#x6539;&#x52A8;&#xFF1B;&#x6700;&#x540E;&#x662F; <code>HEAD</code>&#xFF0C;&#x5B83;&#x6307;&#x5411;&#x4F60;&#x6700;&#x540E;&#x4E00;&#x6B21;&#x63D0;&#x4EA4;&#x7684;&#x7ED3;&#x679C;&#x3002;</p>
<p><img src="http://7jpobz.com1.z0.glb.clouddn.com/trees.png" alt=""></p>
<h2 id="&#x6DFB;&#x52A0;&#x548C;&#x63D0;&#x4EA4;">&#x6DFB;&#x52A0;&#x548C;&#x63D0;&#x4EA4;</h2>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x63D0;&#x51FA;&#x66F4;&#x6539;&#xFF08;&#x628A;&#x5B83;&#x4EEC;&#x6DFB;&#x52A0;&#x5230;&#x6682;&#x5B58;&#x533A;&#xFF09;&#xFF0C;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre><code class="lang-sh">git add &lt;filename&gt;
git add *
</code></pre>
<p>&#x8FD9;&#x662F; git &#x57FA;&#x672C;&#x5DE5;&#x4F5C;&#x6D41;&#x7A0B;&#x7684;&#x7B2C;&#x4E00;&#x6B65;&#xFF1B;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x4EE5;&#x5B9E;&#x9645;&#x63D0;&#x4EA4;&#x6539;&#x52A8;&#xFF1A;</p>
<pre><code class="lang-sh">git commit -m <span class="hljs-string">&quot;&#x4EE3;&#x7801;&#x63D0;&#x4EA4;&#x4FE1;&#x606F;&quot;</span>
</code></pre>
<p>&#x73B0;&#x5728;&#xFF0C;&#x4F60;&#x7684;&#x6539;&#x52A8;&#x5DF2;&#x7ECF;&#x63D0;&#x4EA4;&#x5230;&#x4E86; <strong>HEAD</strong>&#xFF0C;&#x4F46;&#x662F;&#x8FD8;&#x6CA1;&#x5230;&#x4F60;&#x7684;&#x8FDC;&#x7AEF;&#x4ED3;&#x5E93;&#x3002;</p>
<h2 id="&#x63A8;&#x9001;&#x6539;&#x52A8;">&#x63A8;&#x9001;&#x6539;&#x52A8;</h2>
<p>&#x4F60;&#x7684;&#x6539;&#x52A8;&#x73B0;&#x5728;&#x5DF2;&#x7ECF;&#x5728;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x7684; <strong>HEAD</strong> &#x4E2D;&#x4E86;&#x3002;&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x4EE5;&#x5C06;&#x8FD9;&#x4E9B;&#x6539;&#x52A8;&#x63D0;&#x4EA4;&#x5230;&#x8FDC;&#x7AEF;&#x4ED3;&#x5E93;&#xFF1A;</p>
<pre><code class="lang-sh">git push origin master
</code></pre>
<p>&#x53EF;&#x4EE5;&#x628A; <strong><em>master</em></strong> &#x6362;&#x6210;&#x4F60;&#x60F3;&#x8981;&#x63A8;&#x9001;&#x7684;&#x4EFB;&#x4F55;&#x5206;&#x652F;&#x3002;</p>
<p> &#x5982;&#x679C;&#x4F60;&#x8FD8;&#x6CA1;&#x6709;&#x514B;&#x9686;&#x73B0;&#x6709;&#x4ED3;&#x5E93;&#xFF0C;&#x5E76;&#x6B32;&#x5C06;&#x4F60;&#x7684;&#x4ED3;&#x5E93;&#x8FDE;&#x63A5;&#x5230;&#x67D0;&#x4E2A;&#x8FDC;&#x7A0B;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x6DFB;&#x52A0;&#xFF1A;</p>
<pre><code class="lang-sh">git remote add origin &lt;server&gt;
</code></pre>
<p>&#x5982;&#x6B64;&#x4F60;&#x5C31;&#x80FD;&#x591F;&#x5C06;&#x4F60;&#x7684;&#x6539;&#x52A8;&#x63A8;&#x9001;&#x5230;&#x6240;&#x6DFB;&#x52A0;&#x7684;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x53BB;&#x4E86;&#x3002;</p>
<h2 id="&#x5206;&#x652F;">&#x5206;&#x652F;</h2>
<p>&#x5206;&#x652F;&#x662F;&#x7528;&#x6765;&#x5C06;&#x7279;&#x6027;&#x5F00;&#x53D1;&#x7EDD;&#x7F18;&#x5F00;&#x6765;&#x7684;&#x3002;&#x5728;&#x4F60;&#x521B;&#x5EFA;&#x4ED3;&#x5E93;&#x7684;&#x65F6;&#x5019;&#xFF0C;<strong><em>master</em></strong> &#x662F;&#x201C;&#x9ED8;&#x8BA4;&#x7684;&#x201D;&#x5206;&#x652F;&#x3002;&#x5728;&#x5176;&#x4ED6;&#x5206;&#x652F;&#x4E0A;&#x8FDB;&#x884C;&#x5F00;&#x53D1;&#xFF0C;&#x5B8C;&#x6210;&#x540E;&#x518D;&#x5C06;&#x5B83;&#x4EEC;&#x5408;&#x5E76;&#x5230;&#x4E3B;&#x5206;&#x652F;&#x4E0A;&#x3002;</p>
<p><img src="http://7jpobz.com1.z0.glb.clouddn.com/branches.png" alt=""></p>
<p>&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x53EB;&#x505A;&#x201C;feature_x&#x201D;&#x7684;&#x5206;&#x652F;&#xFF0C;&#x5E76;&#x5207;&#x6362;&#x8FC7;&#x53BB;&#xFF1A;</p>
<pre><code class="lang-sh">git checkout -b feature_x
</code></pre>
<p>&#x5207;&#x6362;&#x56DE;&#x4E3B;&#x5206;&#x652F;&#xFF1A;</p>
<pre><code class="lang-sh">git checkout master
</code></pre>
<p>&#x518D;&#x628A;&#x65B0;&#x5EFA;&#x7684;&#x5206;&#x652F;&#x5220;&#x6389;&#xFF1A;</p>
<pre><code class="lang-sh">git branch <span class="hljs-_">-d</span> feature_x
</code></pre>
<p>&#x9664;&#x975E;&#x4F60;&#x5C06;&#x5206;&#x652F;&#x63A8;&#x9001;&#x5230;&#x8FDC;&#x7AEF;&#x4ED3;&#x5E93;&#xFF0C;&#x4E0D;&#x7136;&#x8BE5;&#x5206;&#x652F;&#x5C31;&#x662F; <em>&#x4E0D;&#x4E3A;&#x4ED6;&#x4EBA;&#x6240;&#x89C1;&#x7684;</em>&#xFF1A;</p>
<pre><code class="lang-sh">git push origin &lt;branch&gt;
</code></pre>
<h2 id="&#x66F4;&#x65B0;&#x4E0E;&#x5408;&#x5E76;">&#x66F4;&#x65B0;&#x4E0E;&#x5408;&#x5E76;</h2>
<p>&#x8981;&#x66F4;&#x65B0;&#x4F60;&#x7684;&#x672C;&#x5730;&#x4ED3;&#x5E93;&#x81F3;&#x6700;&#x65B0;&#x6539;&#x52A8;&#xFF0C;&#x6267;&#x884C;&#xFF1A;</p>
<pre><code class="lang-sh">git pull
</code></pre>
<p>&#x4EE5;&#x5728;&#x4F60;&#x7684;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;&#x4E2D; <em>&#x83B7;&#x53D6;</em>&#xFF08;fetch&#xFF09; &#x5E76; <em>&#x5408;&#x5E76;</em>&#xFF08;merge&#xFF09; &#x8FDC;&#x7AEF;&#x7684;&#x6539;&#x52A8;&#x3002;
&#x8981;&#x5408;&#x5E76;&#x5176;&#x4ED6;&#x5206;&#x652F;&#x5230;&#x4F60;&#x7684;&#x5F53;&#x524D;&#x5206;&#x652F;&#xFF08;&#x4F8B;&#x5982; master&#xFF09;&#xFF0C;&#x6267;&#x884C;&#xFF1A;</p>
<pre><code class="lang-sh">git merge &lt;branch&gt;
</code></pre>
<p>&#x5728;&#x8FD9;&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;git &#x90FD;&#x4F1A;&#x5C1D;&#x8BD5;&#x53BB;&#x81EA;&#x52A8;&#x5408;&#x5E76;&#x6539;&#x52A8;&#x3002;&#x9057;&#x61BE;&#x7684;&#x662F;&#xFF0C;&#x8FD9;&#x53EF;&#x80FD;&#x5E76;&#x975E;&#x6BCF;&#x6B21;&#x90FD;&#x6210;&#x529F;&#xFF0C;&#x5E76;&#x53EF;&#x80FD;&#x51FA;&#x73B0;<em>&#x51B2;&#x7A81;</em>&#xFF08;conflicts&#xFF09;&#x3002; &#x8FD9;&#x65F6;&#x5019;&#x5C31;&#x9700;&#x8981;&#x4F60;&#x4FEE;&#x6539;&#x8FD9;&#x4E9B;&#x6587;&#x4EF6;&#x6765;&#x624B;&#x52A8;&#x5408;&#x5E76;&#x8FD9;&#x4E9B;<em>&#x51B2;&#x7A81;</em>&#xFF08;conflicts&#xFF09;&#x3002;&#x6539;&#x5B8C;&#x4E4B;&#x540E;&#xFF0C;&#x4F60;&#x9700;&#x8981;&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x4EE5;&#x5C06;&#x5B83;&#x4EEC;&#x6807;&#x8BB0;&#x4E3A;&#x5408;&#x5E76;&#x6210;&#x529F;&#xFF1A;</p>
<pre><code class="lang-sh">git add &lt;filename&gt;
</code></pre>
<p>&#x5728;&#x5408;&#x5E76;&#x6539;&#x52A8;&#x4E4B;&#x524D;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x9884;&#x89C8;&#x5DEE;&#x5F02;&#xFF1A;</p>
<pre><code class="lang-sh">git diff &lt;<span class="hljs-built_in">source</span>_branch&gt; &lt;target_branch&gt;
</code></pre>
<h2 id="&#x6807;&#x7B7E;">&#x6807;&#x7B7E;</h2>
<p>&#x4E3A;&#x8F6F;&#x4EF6;&#x53D1;&#x5E03;&#x521B;&#x5EFA;&#x6807;&#x7B7E;&#x662F;&#x63A8;&#x8350;&#x7684;&#x3002;&#x8FD9;&#x4E2A;&#x6982;&#x5FF5;&#x65E9;&#x5DF2;&#x5B58;&#x5728;&#xFF0C;&#x5728; SVN &#x4E2D;&#x4E5F;&#x6709;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x53EB;&#x505A; <em>1.0.0</em> &#x7684;&#x6807;&#x7B7E;&#xFF1A;</p>
<pre><code class="lang-sh">git tag 1.0.0 1b2e1d63ff
</code></pre>
<p><em>1b2e1d63ff</em> &#x662F;&#x4F60;&#x60F3;&#x8981;&#x6807;&#x8BB0;&#x7684;&#x63D0;&#x4EA4; ID &#x7684;&#x524D; 10 &#x4F4D;&#x5B57;&#x7B26;&#x3002;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E0B;&#x5217;&#x547D;&#x4EE4;&#x83B7;&#x53D6;&#x63D0;&#x4EA4; ID&#xFF1A;</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">log</span>
</code></pre>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5C11;&#x4E00;&#x70B9;&#x7684;&#x63D0;&#x4EA4; ID &#x524D;&#x51E0;&#x4F4D;&#xFF0C;&#x53EA;&#x8981;&#x5B83;&#x7684;&#x6307;&#x5411;&#x5177;&#x6709;&#x552F;&#x4E00;&#x6027;&#x3002;</p>
<h2 id="&#x66FF;&#x6362;&#x672C;&#x5730;&#x6539;&#x52A8;">&#x66FF;&#x6362;&#x672C;&#x5730;&#x6539;&#x52A8;</h2>
<p>&#x5047;&#x5982;&#x4F60;&#x64CD;&#x4F5C;&#x5931;&#x8BEF;&#xFF08;&#x5F53;&#x7136;&#xFF0C;&#x8FD9;&#x6700;&#x597D;&#x6C38;&#x8FDC;&#x4E0D;&#x8981;&#x53D1;&#x751F;&#xFF09;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x66FF;&#x6362;&#x6389;&#x672C;&#x5730;&#x6539;&#x52A8;&#xFF1A;</p>
<pre><code class="lang-sh">git checkout -- &lt;filename&gt;
</code></pre>
<p>&#x6B64;&#x547D;&#x4EE4;&#x4F1A;&#x4F7F;&#x7528; HEAD &#x4E2D;&#x7684;&#x6700;&#x65B0;&#x5185;&#x5BB9;&#x66FF;&#x6362;&#x6389;&#x4F60;&#x7684;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x3002;&#x5DF2;&#x6DFB;&#x52A0;&#x5230;&#x6682;&#x5B58;&#x533A;&#x7684;&#x6539;&#x52A8;&#x4EE5;&#x53CA;&#x65B0;&#x6587;&#x4EF6;&#x90FD;&#x4E0D;&#x4F1A;&#x53D7;&#x5230;&#x5F71;&#x54CD;&#x3002;</p>
<p>&#x5047;&#x5982;&#x4F60;&#x60F3;&#x4E22;&#x5F03;&#x4F60;&#x5728;&#x672C;&#x5730;&#x7684;&#x6240;&#x6709;&#x6539;&#x52A8;&#x4E0E;&#x63D0;&#x4EA4;&#xFF0C;&#x53EF;&#x4EE5;&#x5230;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x83B7;&#x53D6;&#x6700;&#x65B0;&#x7684;&#x7248;&#x672C;&#x5386;&#x53F2;&#xFF0C;&#x5E76;&#x5C06;&#x4F60;&#x672C;&#x5730;&#x4E3B;&#x5206;&#x652F;&#x6307;&#x5411;&#x5B83;&#xFF1A;</p>
<pre><code class="lang-sh">git fetch origin
git reset --hard origin/master
</code></pre>
<h2 id="&#x5B9E;&#x7528;&#x5C0F;&#x8D34;&#x58EB;">&#x5B9E;&#x7528;&#x5C0F;&#x8D34;&#x58EB;</h2>
<p>&#x5185;&#x5EFA;&#x7684;&#x56FE;&#x5F62;&#x5316; git&#xFF1A;</p>
<pre><code class="lang-sh">gitk
</code></pre>
<p>&#x5F69;&#x8272;&#x7684; git &#x8F93;&#x51FA;&#xFF1A;</p>
<pre><code class="lang-sh">git config color.ui <span class="hljs-literal">true</span>
</code></pre>
<p>&#x663E;&#x793A;&#x5386;&#x53F2;&#x8BB0;&#x5F55;&#x65F6;&#xFF0C;&#x6BCF;&#x4E2A;&#x63D0;&#x4EA4;&#x7684;&#x4FE1;&#x606F;&#x53EA;&#x663E;&#x793A;&#x4E00;&#x884C;&#xFF1A;</p>
<pre><code class="lang-sh">git config format.pretty oneline
</code></pre>
<p>&#x4EA4;&#x4E92;&#x5F0F;&#x6DFB;&#x52A0;&#x6587;&#x4EF6;&#x5230;&#x6682;&#x5B58;&#x533A;&#xFF1A;</p>
<pre><code class="lang-sh">git add -i
</code></pre>
<h2 id="&#x94FE;&#x63A5;&#x4E0E;&#x8D44;&#x6E90;">&#x94FE;&#x63A5;&#x4E0E;&#x8D44;&#x6E90;</h2>
<h3 id="&#x56FE;&#x5F62;&#x5316;&#x5BA2;&#x6237;&#x7AEF;">&#x56FE;&#x5F62;&#x5316;&#x5BA2;&#x6237;&#x7AEF;</h3>
<ul>
<li><a href="http://gitx.laullon.com/" target="_blank">GitX (L) (OSX, &#x5F00;&#x6E90;&#x8F6F;&#x4EF6;)</a></li>
<li><a href="http://www.git-tower.com/" target="_blank">Tower (OSX)</a></li>
<li><a href="http://www.sourcetreeapp.com/" target="_blank">Source Tree (OSX, &#x514D;&#x8D39;)</a></li>
<li><a href="http://mac.github.com/" target="_blank">GitHub for Mac (OSX, &#x514D;&#x8D39;)</a></li>
<li><a href="https://itunes.apple.com/gb/app/gitbox/id403388357?mt=12" target="_blank">GitBox (OSX, App Store)</a></li>
</ul>
<h3 id="&#x6307;&#x5357;&#x548C;&#x624B;&#x518C;">&#x6307;&#x5357;&#x548C;&#x624B;&#x518C;</h3>
<ul>
<li><a href="http://book.git-scm.com/" target="_blank">Git &#x793E;&#x533A;&#x53C2;&#x8003;&#x4E66;</a></li>
<li><a href="http://progit.org/book/" target="_blank">&#x4E13;&#x4E1A; Git</a></li>
<li><a href="http://think-like-a-git.net/" target="_blank">&#x50CF; git &#x90A3;&#x6837;&#x601D;&#x8003;</a></li>
<li><a href="http://help.github.com/" target="_blank">GitHub &#x5E2E;&#x52A9;</a></li>
<li><a href="http://marklodato.github.io/visual-git-guide/index-zh-cn.html" target="_blank">&#x56FE;&#x89E3; Git</a></li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../开发者指南.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 开发者指南">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"git - 简明指南","level":"1.6.1","depth":2,"next":{"title":"Jersey-2.x用户指南","level":"1.6.2","depth":2,"url":"https://waylau.gitbooks.io/jersey-2-user-guide/content/index.html","ref":"https://waylau.gitbooks.io/jersey-2-user-guide/content/index.html","articles":[]},"previous":{"title":"开发者指南","level":"1.6","depth":1,"path":"开发者指南.md","ref":"开发者指南.md","articles":[{"title":"git - 简明指南","level":"1.6.1","depth":2,"path":"git/guide.md","ref":"git/guide.md","articles":[]},{"title":"Jersey-2.x用户指南","level":"1.6.2","depth":2,"url":"https://waylau.gitbooks.io/jersey-2-user-guide/content/index.html","ref":"https://waylau.gitbooks.io/jersey-2-user-guide/content/index.html","articles":[]},{"title":"REST 实战","level":"1.6.3","depth":2,"url":"https://waylau.gitbooks.io/rest-in-action/content/","ref":"https://waylau.gitbooks.io/rest-in-action/content/","articles":[]},{"title":"Java Servlet 3.1 规范","level":"1.6.4","depth":2,"url":"https://github.com/waylau/servlet-3.1-specification","ref":"https://github.com/waylau/servlet-3.1-specification","articles":[]},{"title":"MyBatis中文指南","level":"1.6.5","depth":2,"url":"http://mybatis.github.io/mybatis-3/zh/index.html","ref":"http://mybatis.github.io/mybatis-3/zh/index.html","articles":[]},{"title":"Apache Shiro 用户指南","level":"1.6.6","depth":2,"url":"https://github.com/waylau/apache-shiro-1.2.x-reference","ref":"https://github.com/waylau/apache-shiro-1.2.x-reference","articles":[]},{"title":"Spring Boot参考指南","level":"1.6.7","depth":2,"url":"https://github.com/qibaoguang/Spring-Boot-Reference-Guide/blob/master/SUMMARY.md","ref":"https://github.com/qibaoguang/Spring-Boot-Reference-Guide/blob/master/SUMMARY.md","articles":[]},{"title":"Netty4 用户指南","level":"1.6.8","depth":2,"url":"https://github.com/waylau/netty-4-user-guide/blob/master/SUMMARY.md","ref":"https://github.com/waylau/netty-4-user-guide/blob/master/SUMMARY.md","articles":[]},{"title":"Google Java编程风格指南","level":"1.6.9","depth":2,"path":"user_guide/google-java8-guide.md","ref":"user_guide/google-java8-guide.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"git/guide.md","mtime":"2017-09-01T15:31:07.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-09-01T16:57:38.335Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

